package com.ruoyi.common.config;

import com.ruoyi.common.minio.MyMinioClient;
import io.minio.MinioAsyncClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : weixu
 * @date : 2024/6/28 17:29
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinIoProperties {
    /**
     * minio地址+端口号
     */
    private String endpoint;

    /**
     * minio用户名
     */
    private String accessKey;

    /**
     * minio密码
     */
    private String secretKey;

    /**
     * 文件桶的名称
     */
    private String bucketName;

    @Bean(name = "myMinioClient")
    public MyMinioClient myMinioClient() {
        return new MyMinioClient(
                MinioAsyncClient.builder()
                        .endpoint(this.endpoint)
                        .credentials(this.accessKey, this.secretKey)
                        .build()
        );
    }

}
